<?php
/**
 * Created by PhpStorm.
 * User: tjjs
 * Date: 17-8-8
 * Time: 下午7:33
 */

namespace Utils;



use Workerman\Connection\AsyncTcpConnection;

class Socket_to_restaurant
{

    public function __construct($data)
    {
        $this->data = $data;
        $con = new AsyncTcpConnection('ws://127.0.0.1:8686');

        $con->onConnect = function($con) {

            $con->send($this->data);
        };

//        $con->onMessage = function($con, $data) {
//            echo $data;
//        };

        $con->connect();

    }
}
